<?php 
require 'dbconnect.php';
session_start();
$coursename = $_POST["coursename"];
$section = $_POST["section"];
$semester = $_POST["semester"];
$location = $_POST["location"];
$capacity = $_POST["capacity"];
$availability = $_POST["availability"];
$prereq = $_POST["prereq"];

mysql_query("INSERT INTO Course(CourseName, SectionNo, Prerequisite) VALUES ('$coursename',$section,$prereq)") or die(mysql_error());
$id = mysql_insert_id();
$teacherid = $_SESSION['id'];
mysql_query("INSERT INTO CourseSchedule(CourseID, Semester, Location, Capacity, FacultyID, Availability) VALUES ($id,'$semester','$location',$capacity,$teacherid,$availability)") or die(mysql_error());
$id2 = mysql_insert_id();

$result = mysql_query("Select * from CourseSchedule where CourseScheduleID = $id2") or die(mysql_error());
$row = mysql_fetch_array($result);
header("location: courseschedule.php");

?>